import paho.mqtt.client as mqtt

def on_connect(client, userdata, flags, rc):
    print("Connected with result code: " + str(rc))

def on_message(client, userdata, msg):
    print(msg.topic + " " + str(msg.payload))
client_id = '82362741d2d447c69eb3117223872b1d'
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect('mqtt.chinaseven.com', 1883, 600) # 600为keepalive的时间间隔
client.subscribe('/gw/ac233fc05c58/status', qos=0)
client.loop_forever() # 保持连接